package scenetracer.core.primitive;


import scenetracer.math.Matrix4;
import scenetracer.math.Point3;

public class Box extends TriangleMesh {

	
	
	Matrix4 transf;
	Matrix4 invTransf;
	
//	Al rotar la caja puede ser que haya un plano que corte los puntos definidos como mis y max


	public Box() {    
		
		super();
		//posterior
		this.add( new Triangle( new Point3(-1,1,-1), new Point3(1,1,-1),new Point3(-1,-1,-1)));
		this.add( new Triangle( new Point3(-1,-1,-1), new Point3(1,1,-1),new Point3(1,-1,-1)));

		//frente
		this.add( new Triangle(new Point3(1,1,1), new Point3(-1,1,1), new Point3(-1,-1,1)));
		this.add( new Triangle(new Point3(1,1,1), new Point3(-1,-1,1), new Point3(1,-1,1)));
		//izquierda
		this.add( new Triangle(new Point3(1,1,1), new Point3(1,-1,1), new Point3(1,-1,-1)));
		this.add( new Triangle(new Point3(1,1,1), new Point3(1,-1,-1), new Point3(1,1,-1)));
		//derecha 
		this.add( new Triangle(new Point3(-1,1,1), new Point3(-1,-1,1), new Point3(-1,-1,-1))); 
		this.add( new Triangle(new Point3(-1,1,1), new Point3(-1,-1,-1), new Point3(-1,1,-1)));
		// techo
		this.add( new Triangle(new Point3(-1,1,1), new Point3(1,1,1), new Point3(1,1,-1)));
		this.add( new Triangle(new Point3(-1,1,1), new Point3(1,1,-1), new Point3(-1,1,-1)));
		//piso
		this.add( new Triangle(new Point3(1,-1,1), new Point3(-1,-1,-1),new Point3(1,-1,-1) )); 
		this.add( new Triangle(new Point3(1,-1,1), new Point3(-1,-1,1), new Point3(-1,-1,-1)));		

		this.min=new Point3(-1,-1,-1);
		this.max=new Point3(1,1,1);

		
    }	
	
	
    public void setTransform(Matrix4 transform) {
    	transformMesh(transform);
    	this.transf = transform;
		this.invTransf = transform.inverse();
    }

	public Matrix4 getTransform() {
		return transf;
	}




}
